#include "velocitymode.h"

float(*_sqrtf)(float val) = 0;

float Linear_AccDis(float vs, float ve, float acc)
{
	return ((ve*ve - vs*vs) / (2 * acc));
}

float Linear_DecDis(float vs, float ve, float dec)
{
	return ((vs*vs - ve*ve) / (2 * dec));
}

float Linear_AccTime(float vs, float ve, float acc)
{
	return ((ve - vs) / acc);
}

float Linear_DecTime(float vs, float ve, float dec)
{
	return ((vs - ve) / dec);
}

float Linear_MaxEndSpeed(float vs, float acc, float s)
{	
	return (_sqrtf)?_sqrtf(2 * acc*s + vs*vs):0;
}

float Linear_MaxStartSpeed(float ve, float dec, float s)
{
	return (_sqrtf) ? _sqrtf(2 * dec*s + ve*ve) : 0;
}


float Linear_MaxSteadySpeed(float vs, float ve, float acc, float s)
{
	return (_sqrtf)?_sqrtf(acc*s + ((ve*ve + vs*vs)/2)) : 0;
}